package com.ruoyi.lclook.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lclook.domain.AdMessage;
import com.ruoyi.lclook.service.IAdMessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 落地页留言Controller
 * 
 * @author Choi
 * @date 2021-08-17
 */
@RestController
@RequestMapping("/lclook/adMessage")
public class AdMessageController extends BaseController
{
    @Autowired
    private IAdMessageService adMessageService;

    /**
     * 查询落地页留言列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:adMessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdMessage adMessage)
    {
        startPage();
        List<AdMessage> list = adMessageService.selectAdMessageList(adMessage);
        return getDataTable(list);
    }

    /**
     * 导出落地页留言列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:adMessage:export')")
    @Log(title = "落地页留言", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdMessage adMessage)
    {
        List<AdMessage> list = adMessageService.selectAdMessageList(adMessage);
        ExcelUtil<AdMessage> util = new ExcelUtil<AdMessage>(AdMessage.class);
        return util.exportExcel(list, "落地页留言数据");
    }

    /**
     * 获取落地页留言详细信息
     */
    @PreAuthorize("@ss.hasPermi('lclook:adMessage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adMessageService.selectAdMessageById(id));
    }

    /**
     * 新增落地页留言
     */
    @PreAuthorize("@ss.hasPermi('lclook:adMessage:add')")
    @Log(title = "落地页留言", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdMessage adMessage)
    {
        return toAjax(adMessageService.insertAdMessage(adMessage));
    }

    /**
     * 修改落地页留言
     */
    @PreAuthorize("@ss.hasPermi('lclook:adMessage:edit')")
    @Log(title = "落地页留言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdMessage adMessage)
    {
        return toAjax(adMessageService.updateAdMessage(adMessage));
    }

    /**
     * 删除落地页留言
     */
    @PreAuthorize("@ss.hasPermi('lclook:adMessage:remove')")
    @Log(title = "落地页留言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adMessageService.deleteAdMessageByIds(ids));
    }
}
